package com.example.edu.matcher;

public class CompareIntegerMatcher implements Matcher<Integer> {

    private Integer expect;

    private Boolean great;

    public CompareIntegerMatcher(Integer expect, boolean great) {
        this.expect = expect;
        this.great = great;
    }

    @Override
    public boolean matches(Object item) {
        if (this.great) {
            return Integer.compare((Integer) item, expect) > 0;
        } else {
            return Integer.compare((Integer) item, expect) < 0;
        }
    }

    public static CompareIntegerMatcher lt(Integer expect) {
        return new CompareIntegerMatcher(expect, false);
    }

    public static CompareIntegerMatcher gt(Integer expect) {
        return new CompareIntegerMatcher(expect, true);
    }
}
